package com.wyl.controller

import org.springframework.stereotype.Component
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.servlet.mvc.Controller
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

@Component("/hello2")
class Hello2Controller : Controller {
    init {
        println("Hello2Controller初始化成功")
    }

    override fun handleRequest(request: HttpServletRequest, response: HttpServletResponse): ModelAndView? {
        println("访问了hello接口")
        return ModelAndView().apply {
            addObject("msg", "Hello,SpringMVC")
            viewName = "hello"
        }
    }
}